home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_Arrays_VBScript.asp < prev    next >
Encoding:
Text File  |  1998-05-29  |  2.8 KB  |  113 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <% Option Explicit %>
  3.  
  4. <!*************************
  5. This sample is provided for educational purposes only. It is not intended to be 
  6. used in a production environment, has not been tested in a production environment, 
  7. and Microsoft will not provide technical support for it. 
  8. *************************>
  9.  
  10. <%
  11.     'Declare a simple fixed size array.
  12.     Dim aFixed(4)
  13.  
  14.     'Declare a dynamic (resizable) array.
  15.     Dim aColors()
  16.  
  17.  
  18.     'Assign values to fixed size array.
  19.  
  20.     aFixed(0) = "Fixed"
  21.     aFixed(1) = "Size"
  22.     aFixed(2) = "Array"
  23.     aFixed(3) = "Session ID: " & Session.SessionID
  24.  
  25.  
  26.     'Allocate storage for the array.
  27.     Redim aColors(14)
  28.  
  29.     'Store values representing a simple color table
  30.     'to each of the elements.
  31.  
  32.     aColors(0) = "RED"  '[#FF0000]
  33.     aColors(1) = "GREEN"  '[#008000]
  34.     aColors(2) = "BLUE"  '[#0000FF]
  35.     aColors(3) = "AQUA"  '[#00FFFF]
  36.     aColors(4) = "YELLOW"  '[#FFFF00]
  37.     aColors(5) = "FUCHSIA"  '[#FF00FF]
  38.     aColors(6) = "GRAY"  '[#808080]
  39.     aColors(7) = "LIME"  '[#00FF00]
  40.     aColors(8) = "MAROON"  '[#800000]
  41.     aColors(9) = "NAVY"  '[#000080]
  42.     aColors(10) = "OLIVE"  '[#808000]
  43.     aColors(11) = "PURPLE"  '[#800080]
  44.     aColors(12) = "SILVER"  '[#C0C0C0]
  45.     aColors(13) = "TEAL"  '[#008080]
  46. %>
  47.  
  48. <HTML>
  49.     <HEAD>
  50.         <TITLE>Array Sample</TITLE>
  51.     </HEAD>
  52.  
  53.     <BODY BGCOLOR="White" TOPMARGIN="10" LEFTMARGIN="10">
  54.  
  55.         <!-- Display header. -->
  56.  
  57.         <FONT SIZE="4" FACE="Arial, Helvetica">
  58.         <B>Array Sample</B></FONT><BR>
  59.       
  60.         <HR SIZE="1" COLOR="#000000">
  61.  
  62.         <TABLE CELLPADDING=10 BORDER=1 CELLSPACING=0>
  63.             <TR>
  64.                 <TD BGCOLOR=WHITE>
  65.                     <FONT SIZE="3" FACE="Arial, Helvetica">
  66.                         <B>A Resizable Array</B><BR>
  67.                     </FONT>
  68.                 </TD>
  69.  
  70.                 <TD BGCOLOR=WHITE>
  71.                     <FONT SIZE="3" FACE="Arial, Helvetica">
  72.                         <B>A Fixed Size (4 element) Array</B><BR>
  73.                     </FONT>
  74.                 </TD>
  75.             </TR>
  76.  
  77.             <TR>                
  78.                 <TD>
  79.                     <%
  80.                         Dim intColors
  81.                         Dim i 
  82.  
  83.                         'Calculate array size.
  84.                         intColors = UBound(aColors)
  85.  
  86.                         'Print out contents of resizable array into
  87.                         'table column.
  88.  
  89.                         For i = 0 To intColors - 1
  90.                             Response.Write("<FONT COLOR=" & Chr(34) & aColors(i) & Chr(34) &">" & aColors(i) &"<br></FONT>")
  91.                         Next
  92.                     %>
  93.                 </TD>
  94.  
  95.                 <TD>
  96.                     <%
  97.                         'Calculate Array Size.                                                
  98.                         intColors = UBound(aFixed)
  99.  
  100.  
  101.                         'Print out contents of fixed array into table
  102.                         'column.
  103.  
  104.                         For i = 0 To intColors -1                        
  105.                             Response.Write(aFixed(i) & "<br>")
  106.                         Next 
  107.                     %>
  108.                 </TD>
  109.             </TR>
  110.         </TABLE>
  111.     </BODY>
  112. </HTML>
  113.